<template>
    <div class="cube" :style="{scale: scale}">
        <div class="top">
            {{ info.top }}
        </div>
        <div class="surface">
            <span class="flex-center" style="--i:0;color: var(--main-1-h8)">{{ info.i1}}</span>
            <span class="flex-center" style="--i:1;color: var(--main-1-h8)">{{ info.i2}}</span>
            <span class="flex-center" style="--i:2;color: var(--main-1-h8)">{{ info.i3}}</span>
            <span class="flex-center" style="--i:3;color: var(--main-1-h8)">{{ info.i4}}</span>
        </div>
    </div>
</template>

<script setup lang="ts">
const props = defineProps({
    scale: {
        type: Number,
        default: 1,
    },
    info: {
        type: Object as () => {
            top: string
            i1: string
            i2: string
            i3: string
            i4: string
        },
        default: () => ({
            top: '',
            i1: "",
            i2: "",
            i3: "",
            i4: "",
        }),
    }
})
</script>

<style scoped lang="scss">
.cube {
  position: relative;
  width: 2rem;
  height: 2rem;
  transform-style: preserve-3d;
  animation: cubeRotate 4s linear infinite;
  margin: 0 auto;

  .top {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--main-1-h2);
    transform: rotateX(90deg) translateZ(1rem);
    transform-style: preserve-3d;
    font-size: 0.5rem;
    color: var(--main-1);
    display: flex;
    align-items: center;
    justify-content: center;

    &::before {
      content: '';
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      background: var(--main-2);
      transform: translateZ(-2.4rem);
      filter: blur(0.6rem);
      box-shadow: 0 0 0.1rem var(--main-2-ha1),
      0 0 0.2rem var(--main-2-ha2),
      0 0 0.4rem var(--main-2-ha3);
    }
  }

  .surface {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;

    span {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      background: linear-gradient(180deg, var(--main-1-h2) 10%, var(--main-1) 96%, var(--main-2) 100%);
      transform: rotateY(calc(90deg * var(--i))) translateZ(0.99rem);
    }
  }
}

@keyframes cubeRotate {
  0% {
    transform: rotateX(-30deg) rotateY(0deg);
  }
  100% {
    transform: rotateX(-30deg) rotateY(-360deg);
  }
}
</style>